<!DOCTYPE html>
<html>
<head>
<title>任务菜单</title>
<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
<meta charset="UTF-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="/css/font.css">
<link rel="stylesheet" href="/css/xadmin.css">
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/xadmin.js"></script>
</head>
<script type="text/javascript">
	//layui table 渲染绑定
	layui.use('table', function() {
		var wallet = "";
		var table = layui.table;
		
		$.ajax({                    
	        url : "/../WstLogMoneys/getMoney",
	        async:false, 
	        type : "POST",
	        success : function(data) {
	        	wallet = data;
	        },                
	    }); 
		var money = wallet.walletMoney;
	   $(document).ready(function(){
	    	$("#money").attr('value',money);
	    });
	    
		table.render({
			elem : '#billTable',//table元素的id
			id : "billTable",
			url : '/../WstLogMoneys/list',
			page : true //开启分页
			,
			limit : 5 // 一页多少条
			,
			limits : [ 5, 10, 15, 20 ] // 数据分页条
			,
			cols : [ [ {
				type  : 'numbers',
				title : '序号',
				align : 'center',
				sort  : true,
				width : 80
			}, {
				field : 'wlmCreateTime',
				title : '时间',
				align : 'center',
				width : 230
			}, {
				field : 'wlmDataSrc',
				title : '类型',
				align : 'center',
				width : 200,
				templet : function(row) {
					if(row.wlmDataSrc==1){
						return "充值";
					}else if(row.wlmDataSrc==2){
						return "提现";
					}else if(row.wlmDataSrc==3){
						return "收入";
					}else {
						return "支出";
					}
				}
			}, {
				field : 'wlmMoney',
				title : '金额',
				align : 'center',
				width : 200,
				templet : function(row) {
					if(row.wlmDataSrc==1 || row.wlmDataSrc==3){
						return "+"+row.wlmMoney;
					}else {
						return "-"+row.wlmMoney;
					}
				}
			},{
				field : 'moneys',
				title : '余额',
				align : 'center',
				width : 200,
				templet : function(row) {
					if(row.numbers==1) {
						return money;
					}else if(row.wlmDataSrc==1 || row.wlmDataSrc==3){
						money = money+row.wlmMoney;
						return money;
					}else {
						money = money-row.wlmMoney;
						return money;
					}
				}
			} ] ]
		});
		
		//模糊分页查询
		$('#query').on('click', function() {
			// 重新加载数据表格
			table.reload("billTable", {
				page : {
					curr : 1
				},
				//where 就是对这个表格设置查询条件的  它都是 一key  value 的方式来的
				where : {
					"product.prodName" : $("#prodName").val(),
					stkWarehouse : $("#stkWarehouse").val(),
				}
			})
		});

	});
</script>
<body>
	<div class="x-nav">
		<cite>我的钱包</cite>
		<a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			onclick="location.reload()" title="刷新"> <i
			class="layui-icon layui-icon-refresh" style="line-height: 30px"></i>
		</a>
	</div>

	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div align="center">
						<div align="center" style="font-size: 30px;color: red;">当前余额：
							<input type="text" id="money" name="money" autocomplete="off" value="0" readonly>
						</div>
						<hr />
					</div>
					<div align="center">
						<button type="button" class="layui-btn layui-btn-normal layui-btn-radius">充值</button>
						<hr />
					</div>
					<div align="center">
						<button type="button" class="layui-btn layui-btn-radius">提现</button>
						<hr />
					</div>
					<!-- 这个div是模糊查询form布局的div -->
					<div class="layui-card-body " align="center">
						<!-- 模糊查询 -->
						<form class="layui-form layui-col-space5">

							<div class="layui-input-inline layui-show-xs-block">
								<input class="layui-input" type="text" placeholder="截止日期之后"
									name="prodName" id="prodName">
							</div>

							<div class="layui-input-inline layui-show-xs-block">
								<input class="layui-input" type="text" placeholder="截止日期之前"
									name="stkWarehouse" id="stkWarehouse">
							</div>

						</form>
					</div>
					<div class="layui-card-body ">
						<!-- table 中的id 是用来绑定datagrid数据表格的  lay-filter 用来绑定监听数据表格中的按钮时间的 比如 每一行数据的操作列中 的查询详情  修改  删除功能 监听就需要用到 lay-filter -->
						<table class="layui-table layui-form" id="billTable"
							lay-filter="billTable">
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>